# -*- coding: UTF-8 -*-
from enum import Enum


class ErrorCode(Enum):
    # 通用异常code
    UNKNOWN_ERROR_CODE = 10000
    # 基类必须继承自Base
    EXTEND_BASE_ERROR_CODE = 10001


exception_mapping_dict = {}
exception_mapping_dict[10000] = "未知异常"
exception_mapping_dict[10001] = "基类必须继承自Base"


class CustomException(Exception):
    def __init__(self, code, message):
        super().__init__(message)
        self.message = message
        self.code = code


def get_exception(code=00000):
    return CustomException(code, exception_mapping_dict[code])
